package lambda;

import java.util.function.Function;

/**
 * 函数接口：输入参数，得到结果
 */
public class FunctionTest {
    public static void main(String[] args) {
        getNum(str -> Integer.parseInt(str));
        getNum(str -> Integer.parseInt(str), num -> num * 5);
    }

    /**
     * 单次处理
     */
    public static void getNum(Function<String, Integer> function) {
        Integer num = function.apply("10");
        System.out.println("num = " + num);
    }

    /**
     * 多次处理
     */
    public static void getNum(Function<String, Integer> f1, Function<Integer, Integer> f2) {
        Integer num = f1.andThen(f2).apply("10");
        System.out.println("num = " + num);
    }
}
